home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / include / disk.h < prev    next >
C/C++ Source or Header  |  1992-12-09  |  6KB  |  173 lines

  1. /*
  2.  * disk.h --
  3.  *
  4.  *    Definitions for utilities that examine an OFS filesystem through
  5.  *    a raw disk interface.
  6.  *
  7.  * Copyright 1990 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * $Header: /sprite/src/lib/disk/RCS/disk.h,v 1.4 91/10/07 17:40:43 voelker Exp $ SPRITE (Berkeley)
  17.  */
  18.  
  19. #ifndef _DISK
  20. #define _DISK
  21.  
  22. #include <sys/file.h>
  23.  
  24. #include <kernel/fs.h>
  25. #include <kernel/dev.h>
  26. #include <kernel/fsdm.h>
  27. #include <kernel/ofs.h>
  28. #include <kernel/devDiskLabel.h>
  29.  
  30. /*
  31.  * include files for LFS structures and constants
  32.  */
  33. #include <kernel/lfsDesc.h>
  34. #include <kernel/lfsDescMap.h>
  35. #include <kernel/lfsFileLayout.h>
  36. #include <kernel/lfsSegLayout.h>
  37. #include <kernel/lfsStableMem.h>
  38. #include <kernel/lfsSuperBlock.h>
  39. #include <kernel/lfsUsageArray.h>
  40.  
  41. /*
  42.  * These should be here.  They should be in some machine dependent header
  43.  * file.  But for now ...
  44.  */
  45. #define BITS_PER_BYTE           8
  46. #define BITS_PER_INT            32
  47.  
  48. /*
  49.  * DISK_SECTORS_PER_BLOCK    Number of disk sectors per file system block.
  50.  * DISK_KBYTES_PER_BLOCK    Number of kbyte chunks per file system block.
  51.  */
  52. #define DISK_SECTORS_PER_BLOCK       (FS_BLOCK_SIZE / DEV_BYTES_PER_SECTOR)
  53. #define DISK_KBYTES_PER_BLOCK        (FS_BLOCK_SIZE / 1024)
  54.  
  55. /*
  56.  * Maximum number of partitions on a disk.
  57.  */
  58. #define DISK_MAX_PARTS 8
  59.  
  60. /*
  61.  * Maximum length of an ascii label inside a disk label.
  62.  */
  63. #define DISK_MAX_ASCII_LABEL 256
  64.  
  65. /*
  66.  * We understand two types of native disk labels: Sun labels and DEC labels.
  67.  */
  68.  
  69. typedef int Disk_NativeLabelType;
  70.  
  71. #define DISK_NO_LABEL  ((Disk_NativeLabelType) 0)
  72. #define DISK_SUN_LABEL ((Disk_NativeLabelType) 1)
  73. #define DISK_DEC_LABEL ((Disk_NativeLabelType) 2)
  74.  
  75. /*
  76.  * Information about a disk partition.
  77.  */
  78. typedef struct Disk_Partition {
  79.     int        firstCylinder;        /* First cylinder in partition. */
  80.     int        numCylinders;        /* Number of cylinders in partition.*/
  81. } Disk_Partition;
  82.  
  83. /*
  84.  * This is a canonical disk label.  The use of this structure allows
  85.  * programs to read and write disk labels without worrying about
  86.  * the format of the machine-specific disk label.  Fields labelled (RO)
  87.  * are read-only.  They should not be modified by a user program.
  88.  * Fields labelled (+) can be modified by user programs, but the results
  89.  * may not be what is desired.  These fields reflect the location and size
  90.  * of other data structures on the disk.  Simply changing them in the
  91.  * label will not suffice.  The data structures will have to be moved also.
  92.  * For some types of machines it is not possible to change these fields
  93.  * because their location is hard-wired into the prom.  Refer to the prom
  94.  * documentation and kernel source code.  The bottom line is you don't
  95.  * want to change the (+) fields unless you really know what you're doing.
  96.  */
  97. typedef struct Disk_Label {
  98.     int    numHeads;        /* Number of heads */
  99.     int    numSectors;        /* Number of sectors per track */
  100.     int numCylinders;        /* Number of cylinders on the disk. */
  101.     int numAltCylinders;    /* Number of alternate cylinders. */
  102.     char asciiLabel[DISK_MAX_ASCII_LABEL];    /* Ascii label. */
  103.     Disk_Partition partitions[DISK_MAX_PARTS]; /* Partition map */
  104.     Disk_NativeLabelType labelType; /* Type of native disk label */
  105.     char *labelPtr;        /* Pointer to native disk label. */
  106.     int    bootSector;        /* (+) Starting sector of boot program */
  107.     int    numBootSectors;     /* (+) Number of boot sectors. */
  108.     int    summarySector;        /* (+) Start of summary information. */
  109.     int    numSummarySectors;     /* (+) Number of sectors in summary info. */
  110.     int domainSector;        /* (+) Sector where domain header starts. */
  111.     int numDomainSectors;    /* (+) Number of sectors in domain header. */
  112.     int numPartitions;        /* (RO) Number of partitions on disk. */
  113.     int asciiLabelLen;        /* (RO) Length of ascii label. */
  114.     int labelSector;        /* (RO) Location of native disk label. */
  115. } Disk_Label;
  116.  
  117. /*
  118.  * Return values for Disk_HasFilesystem.
  119.  */
  120. #define DISK_HAS_NO_FS   0
  121. #define DISK_HAS_OFS     1
  122. #define DISK_HAS_LFS     2
  123.  
  124. /*
  125.  * Forward Declarations.
  126.  */
  127. Disk_Label        *Disk_ReadLabel();
  128. int            Disk_WriteLabel();
  129. int            Disk_EraseLabel();
  130. Disk_Label        *Disk_NewLabel();
  131. Dec_DiskLabel        *Disk_ReadDecLabel();
  132. Sun_DiskLabel        *Disk_ReadSunLabel();
  133. Fsdm_DiskHeader        *Disk_ReadDiskHeader();
  134. Ofs_SummaryInfo        *Disk_ReadSummaryInfo();
  135. int            Disk_WriteSummaryInfo();
  136. Ofs_DomainHeader    *Disk_ReadDomainHeader();
  137. int            Disk_WriteDomainHeader();
  138. void            Disk_PrintDomainHeader();
  139. void            Disk_PrintSummaryInfo();
  140. int            Disk_BlockWrite();
  141. int            Disk_SectorWrite();
  142. int            Disk_BlockRead();
  143. int            Disk_SectorRead();
  144. int            Disk_BadBlockRead();
  145. void            Disk_PrintLabel();
  146. char            *Disk_GetLabelTypeName();
  147. void            Disk_PrintFileDescBitmap();
  148. void            Disk_PrintDataBlockBitmap();
  149. void            Disk_PrintDirEntry();
  150.  
  151.  
  152. int                     Disk_HasFilesystem();
  153. LfsSuperBlock*          Disk_ReadLfsSuperBlock();
  154. ReturnStatus            Disk_WriteLfsSuperBlock();
  155. LfsCheckPointHdr*       Disk_ReadLfsCheckPointHdr();
  156. ReturnStatus            Disk_WriteLfsCheckPointHdr();
  157. ReturnStatus            Disk_WriteLfsCheckPointArea();
  158. LfsCheckPointTrailer*   Disk_LfsCheckPointTrailer();
  159. ReturnStatus            Disk_ForEachCheckPointRegion();
  160. void                    Disk_PrintLfsSuperBlockHdr();
  161. void                    Disk_PrintLfsStableMemParams();
  162. void                    Disk_PrintLfsDescMapParams();
  163. void                    Disk_PrintLfsSegUsageParams();
  164. void                    Disk_PrintLfsFileLayoutParams();
  165. void                    Disk_PrintLfsSuperBlock();
  166. void                    Disk_PrintLfsCheckPointHdr();
  167. void                    Disk_PrintLfsCheckPointRegion();
  168. void                    Disk_PrintLfsCheckPointTrailer();
  169.  
  170. #endif DISK
  171.  
  172.  
  173.